<template>
  <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
    <el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="80px" style="width: 80%; margin-left:50px;">
      <el-row :gutter="40">
        <el-col :span="24">
          <el-form-item label="服务名称" prop="serviceName">
            <el-input v-model="temp.marketServiceIntegration.serviceName" disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="调用者ip" prop="callerIp">
            <el-input v-model="temp.callerIp" disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="调用请求头" prop="callerHeader">
            <el-input v-model="temp.callerHeader"  disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="调用请求参数" prop="callerParam">
            <el-input v-model="temp.callerParam"  disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="调用报文" prop="callerSoap">
            <el-input v-model="temp.callerSoap"  disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="调用耗时" prop="time">
            <el-input v-model="temp.time" disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="状态" prop="status">
            <el-select v-model="temp.status" class="filter-item" placeholder="请选择状态" disabled>
              <el-option
                v-for="item in dictList('is_success')"
                :key="'type' + item.label"
                :label="item.label"
                :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="调用时间" prop="callerDate">
            <el-date-picker v-model="temp.callerDate" disabled/>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">
        {{ $t('table.cancel') }}
      </el-button>
<!--      <el-button type="primary" :loading="loading" @click="dialogStatus==='create'?createData():updateData()">-->
<!--        {{ $t('table.confirm') }}-->
<!--      </el-button>-->
    </div>
  </el-dialog>
</template>

<script>
import { createMarketServiceLog, updateMarketServiceLog, getMarketServiceLog } from '@/api/marketservicelog/marketServiceLog'

export default {
  name: 'MarketServiceLogForm',
  data() {
    return {
      rules: {
      },
      temp: {},
      textMap: {
        update: '详情'
      },
      loading: false,
      dialogFormVisible: false,
      dialogStatus: ''
    }
  },
  methods: {
    getList() {
      this.$emit('refreshList')
    },
    resetTemp() {
      this.loading = false
      this.temp = {
        id: undefined,
              serviceId: undefined,
              callerId: undefined,
              serviceName: undefined,
              callerIp: undefined,
              callerHeader: undefined,
              callerParam: undefined,
              callerSoap: undefined,
              time: undefined,
              msg: undefined,
              status: undefined,
              tenantId: undefined,
              callerDate: undefined
            }
    },
    handleUpdate(id) {
      this.resetTemp()
      this.dialogStatus = 'update'
      this.dialogFormVisible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
      getMarketServiceLog(id).then(response => {
        if (response.data.code === 0) {
          this.temp = response.data.data
        } else {
          this.dialogFormVisible = false
          this.$message.error(response.data.msg)
        }
      })
    }
  }
}
</script>
